Imports System.Data.Common

Partial Class Presentation_DailyActivity
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim RightNow As Date = Now.AddHours(11).AddMinutes(30)
        Dim TDate As String = RightNow.Year & "/" & RightNow.Month & "/" & RightNow.Day
        Dim MyParams(0) As GenParameter
        Dim Sql As String
        Dim CountSql As String

        Page.Title = "View Today's Activities"

        CountSql = "SELECT COUNT(*)" & _
        " FROM ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN ContactMaster ON ClientMaster.ClientID = ContactMaster.ClientID) INNER JOIN WorkflowMaster AS M ON ClientMaster.ClientID = M.ClientID" & _
         " WHERE M.DateofNextAction = '" & TDate & "' AND ContactMaster.DecisionMaker = 1 AND M.ExecutiveID = ?ExecutiveID AND M.ClientID NOT IN (Select ClientID from WorkflowMaster where InteractionID > M.InteractionID)"
               

        Sql = "SELECT DATE_FORMAT(M.MeetingDate,'%d/%m/%y') AS 'Meeting Date', ClientMaster.ClientName, M.Details, M.NextAction, DATE_FORMAT(M.DateofNextAction,'%d/%m/%y') AS 'Date Next Action', ContactMaster.ContactName, ContactMaster.Designation, ContactMaster.Telephone, ContactMaster.ContactEmail" & _
            " FROM ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN ContactMaster ON ClientMaster.ClientID = ContactMaster.ClientID) INNER JOIN WorkflowMaster AS M ON ClientMaster.ClientID = M.ClientID" & _
            " WHERE M.DateofNextAction = '" & TDate & "' AND ContactMaster.DecisionMaker = 1 AND M.ExecutiveID = ?ExecutiveID AND M.ClientID NOT IN (Select ClientID from WorkflowMaster where InteractionID > M.InteractionID)"

        MyParams(0) = New GenParameter("?ExecutiveID", Request.Cookies("Profile").Item("ExecutiveID"), Data.DbType.UInt32)

        DailyActivities.Sql = Sql
        DailyActivities.Params = MyParams
        DailyActivities.CountSql = CountSql
        DailyActivities.ShowButton = False



    End Sub
End Class
